package net.huashitong.interview.service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;
import net.huashitong.interview.dao.EnterpriseFuWuDao;
import net.huashitong.interview.dao.EnterpriseRegisterDao;
import net.huashitong.interview.entity.EnterpriseFuWu;
import net.huashitong.interview.entity.EnterpriseRegister;
import net.huashitong.interview.filter.EnterpriseRegisterFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.misc.Regexp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EnterpriseRegisterService extends StringPKService<EnterpriseRegister> {

    @Autowired
    private EnterpriseRegisterDao dao;
    @Autowired
    private SysTableService tableService;

    @Override
    protected BaseDao<EnterpriseRegister, String> getDao() {
        return dao;
    }
    @Override
    protected void beforeSave(EnterpriseRegister obj) {
        obj.setSysId(tableService.updateMaxSysId("t_gis_interviewEnterpriseRegister", null));
    }

    public List<EnterpriseRegister> queryRegister(EnterpriseRegisterFilter filter){
        List<EnterpriseRegister> list = dao.queryRegister(filter);
        return list;
    }

    public List<Map<String,Object>> baseResult(List<EnterpriseRegister> list){
        List<Map<String, Object>> result = new ArrayList<>();
        for(EnterpriseRegister register : list){
            Map<String,Object> map = new HashMap<>();
            map.put("sysId",register.getSysId());
            map.put("leaderName",register.getLeaderName());
            map.put("interviewEnterprise",register.getInterviewEnterprise());
            map.put("interviewDate",register.getInterviewDate());
            map.put("situation",register.getSituation());
            result.add(map);
        }
        return result;
    }

    public String getNewFillDate(){
        return dao.getNewFillDate();
    }
}
